var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    detailData: {},
    imgUrls: [],
    imgUrls2: [],
    isshare:false,
    indicatorDots: true,
    autoplay: true,
    interval: 5000,
    duration: 1000,
    goodsid:''
  },
  gopay: function(e) {
    // console.log(e);
    var goodsid = e.currentTarget.dataset.goodsid;
    var goodsimg = e.currentTarget.dataset.goodsimg;
    var goodsmoney = e.currentTarget.dataset.goodsmoney;
    var goodsname = e.currentTarget.dataset.goodsname;
    wx.navigateTo({
      url: '/pages/payorder/payorder?goodsid=' + goodsid + '&goodsimg=' + goodsimg + '&goodsname=' + goodsname + '&goodsmoney=' + goodsmoney
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  gomain(){
    wx.switchTab({
      url: '/pages/main/main',
    })
  },
  onLoad: function(options) {
    var that=this;
    console.log(options);
    wx.showLoading({
      title: '正在加载...',
    })
    if (options.isshare==1) {
      that.setData({
        isshare:true
      })
    }


    var that = this;
    wx.request({
      url: app.serverUrl + 'About/goodsDetail',
      // header: { 'content-type': 'application/x-www-form-urlencoded' },
      method: 'GET',
      dataType: 'json',
      data: {
        openid: app.openid,
        goodsid: options.goodsid,
        paimai: 'g'
      },
      success: function(res) {

        console.log(res);
        that.setData({
          detailData: res.data.data,
          imgUrls: res.data.data.goodsbanner,
          imgUrls2: res.data.data.goodsimages,
          goodsid:res.data.data.goodsid
        });
        wx.hideLoading()
      }

    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function(res) {
    var that = this;
    if (res.from === 'button') {
    }
    return {
      title: '大易益·传统文化大舞台，爱好者的掌中宝！',
      path: 'pages/fpdetail/fpdetail?goodsid=' + that.data.goodsid+'&isshare=1',
      success: function (res) {
        console.log('成功', res)
      }
    }
  }
})